/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package TestEJBclient;

import cms.sessionbean.ConferenceApplicationsRemote;
import cms.sessionbean.ConferenceItemApplicationRemote;
import cms.sessionbean.PaymentMgmtRemote;
import cms.sessionbean.ReviewMgmtRemote;
import cms.sessionbean.UserPortfoiloRemote;
import dto.Conference;
import dto.Conferenceitem;
import dto.ConferenceitemId;
import dto.Timeline;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.naming.InitialContext;
import javax.naming.NamingException;

/**
 *
 * @author dwu
 */
public class TestEjbClient {
    @SuppressWarnings("empty-statement")
    public static void main(String[] argv) throws NamingException, ParseException{
        InitialContext ctx  = new InitialContext();
        ConferenceApplicationsRemote conBean = (ConferenceApplicationsRemote) ctx.lookup("ConferenceApplications");
        UserPortfoiloRemote usrBean = (UserPortfoiloRemote) ctx.lookup("UserPortfoilo");
        PaymentMgmtRemote  payBean  = (PaymentMgmtRemote) ctx.lookup("PaymentMgmt");
        ReviewMgmtRemote  revBean   =(ReviewMgmtRemote) ctx.lookup("ReviewMgmt");
        System.out.println( "getAllReviewCategory:"+ revBean.getAllReviewCategory().size());
        
         System.out.println( "getReviewCategory :"+ revBean.getReviewCategory("3eb15024-4096-11e2-84e4-001c257e2be9").getWeight());
         
         System.out.println( "getReviewcContentsByCategoryName:"+ revBean.getReviewcContentsByCategoryName("Quality of the Research").size());
         
         System.out.println( "getReviewcContents:"+ revBean.getReviewcContents("746b94c6-40ab-11e2-84e4-001c257e2be9"));
         
         
        
        System.out.println("get Participant:"+payBean.getConferencesParticipant("EnviromentJapan").get(0).getRegisterDate());
        
        System.out.println(usrBean.userLogin("ABC", "123456", "a"));
        
        
        System.out.println("abc pass:"+usrBean.getUser("ABC").getPassword());
        
        
        for(int i = 0; i< conBean.getAllConferences().size();i++) {
            System.out.println("Testing get all conference:"+i+ " ==>" + conBean.getAllConferences().get(i).getConferenceName());
        }
     /*   
           String name = "EnviromentJapan11";
           String eventDetail = "To dicuss the jap enviroment11";
           String location = "Janpan11";
           boolean callForPaper = false;
           Date submitDate = new Date();
           boolean notifyResults = false;
           double price = 23.0;
        
          Conference conf1 = new Conference(name, eventDetail, location, callForPaper, submitDate, notifyResults, price,0) ;
          conBean.saveConference(conf1);
          System.out.println("Testing get Conference by name:"+conBean.getConference(name).getLocatoin());
          
          SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd");
          Date registerFrom = formatter.parse("2012/12/04");
          Date registerTo = formatter.parse("2012/12/10");
          Date reviewFrom = formatter.parse("2012/12/11");
          Date reviewTo = formatter.parse("2012/12/13");
          Date holdFrom = formatter.parse("2012/12/14");
          Date holdTo = formatter.parse("2012/12/14");
          Timeline timewindow =   new Timeline( name, registerFrom,  registerTo,  reviewFrom,  reviewTo,  holdFrom,  holdTo);
          conBean.updateTimeLine(timewindow);
         
          Timeline timewindow2 =   new Timeline( "MobileAppDev", registerFrom,  registerTo,  reviewFrom,  reviewTo,  holdFrom,  holdTo);
          conBean.updateTimeLine(timewindow2);
         
          System.out.println("Testing TimeLine:"+conBean.getTimeLines(name).getHoldFrom());
          for(Conference c:conBean.getAllOpenConferences()){
              System.out.println("Testing Open Conference:"+c.getConferenceName() +"price:"+c.getPrice());
          }
          
         System.out.println("Tesing participantConference:"+ conBean.participantConference("ABC", name).getRegisterDate());
         System.out.println("Tesing participantConference:"+ conBean.participantConference("ABC", "Mobile App Dev").getRegisterDate());
          System.out.println("Tesing participantConference:"+ conBean.participantConference("ABC", "Web App Dev").getRegisterDate());
       
         System.out.println("Testing getConferencesByBookedUser:" +
         conBean.getConferencesByBookedUser("ABC").get(0).getConferenceName());
         System.out.println("Tesing unParticipantConference:"+ conBean.unParticipantConference("ABC", "Web App Dev"));
         System.out.println( "Testign deleteTimeLine:"+conBean.deleteTimeLine("Mobile App Dev"));
         System.out.println("Testing getConferencesByType:"+conBean.getConferencesByType(0).get(0).getEventDetail());  ;
    
    //--------------------------------ConferenceItemApplicationRemote testing-----------------------------------------------------
     System.out.println("-------------------------------ConferenceItemApplicationRemote testing-------------------");
     ConferenceItemApplicationRemote itemBean = (ConferenceItemApplicationRemote) ctx.lookup("ConferenceItemApplication");
     ConferenceitemId id1 = new ConferenceitemId("Mobile App Dev","ios book") ;
     Conferenceitem item1 ;
     item1 =new Conferenceitem(id1, "IPHONE 5 tranning softcopy",  1,  "c:\\hello",  1, 2.0,  true);
     System.out.println("addConferenceItem:"+itemBean.addConferenceItem(item1));
     System.out.println("addConferenceItem:"+itemBean.getAllConferenceItems().get(0).getFilePath());
     System.out.println("bookConferenceItem:"+itemBean.bookConferenceItem("ABC", "Mobile App Dev", "ios book").getPrice());
     System.out.println("getAllConferenceItems:"+itemBean.getAllConferenceItems().get(0).getIsBlindReivew()); 
     System.out.println("getConferenceItem:"+itemBean.getConferenceItem("Mobile App Dev", "ios book").getItemDescription()); 
    
   */
      
    }
}
